using Engine;
using Engine.Graphics;
using Game;

namespace SCIENEW {
    /// <summary>
    /// 对应原版FlatBlock，平面物品
    /// </summary>
    public class FlatDamageableItem : DefaultDamageableItem {
        public int DefaultTextureSlot;
        public string Id;
        public Color Color = Color.White;
        public int Durability;

        public FlatDamageableItem(string name, string id, string des, int textureSlot, Color color, int durability) {
            DefaultTextureSlot = textureSlot;
            Id = id;
            DisplayName = name;
            Description = des;
            Color = color;
            Durability = durability;
        }


        public override int GetFaceTextureSlot(int face, int value) => DefaultTextureSlot;

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) {
            BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, IndustrialModLoader.IETexture, Color * color, false, environmentData);
        }

        public override Vector3 GetIconViewOffset(int value, DrawBlockEnvironmentData environmentData) => new Vector3 { Z = 1 };

        public override string GetCraftingId() => Id ?? GetType().Name;

        public override int GetDurability(int value) => Durability;
    }
}